package com.imCode.web;

import com.alibaba.fastjson.JSON;
import com.imCode.web.model.readTxt;
import com.imCode.web.model.student;
import com.imCode.web.model.user;
import jdk.nashorn.internal.runtime.linker.LinkerCallSite;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by GO FOR IT on 2020/4/16.
 */
@WebServlet(urlPatterns = {"/d2", "/list"}, loadOnStartup = 0)
public class DemoServlet02 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

//        String name = request.getParameter("name");
//        System.out.println("name = "+name);
//        response.getWriter().print("Hello "+name);


        response.setContentType("text/html;charset=UTF-8");
//        readTxt read = new readTxt();
//        List<student> list = read.getStu();
        List<student> list = new ArrayList<>();
        list.add(new student("12", "31", "42142", "312", "312"));
        response.getWriter().println(JSON.toJSONString(list));

    }
}
